//
//  EFReturnFolderUnFolerCell.m
//  EnjogFood
//
//  Created by 王芳 on 17/6/11.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFReturnFolderUnFolerCell.h"
#import "EFReturnFoldUnFoldItem.h"

@interface EFReturnFolderUnFolerCell ()
@property (strong, nonatomic) UILabel *titlelabel;
@property (strong, nonatomic) UIView *line;
@end

@implementation EFReturnFolderUnFolerCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self initUI];
    }
    return self;
}

- (void)initUI{
    [self.contentView addSubview:self.titlelabel];
    [self.contentView addSubview:self.arrowImageV];
       [self.contentView addSubview:self.line];
}

- (void)setObject:(EFReturnFoldUnFoldItem *)item{
    if (item.isDown) {
        self.arrowImageV.image = IMG(@"putaway_icon_default");
    }else{
        self.arrowImageV.image = IMG(@"unfolded_icon__default");
    }
    self.titlelabel.text = item.title;
    [self.titlelabel sizeToFit];
    self.titlelabel.left = 20;
    self.titlelabel.top = 18;
    self.line.left = 20;
    
    self.arrowImageV.top = 18;
    self.arrowImageV.right = kScreenWidth - 17;
    self.line.bottom = self.height;
}

- (UILabel *)titlelabel{
    if (!_titlelabel) {
        _titlelabel = [[UILabel alloc] init];
        _titlelabel.font = [UIFont systemFontOfSize:13];
        _titlelabel.textColor = kBlack333;
    }
    return _titlelabel;
}

- (UIImageView *)arrowImageV{
    if (!_arrowImageV) {
        _arrowImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
        _arrowImageV.image = IMG(@"putaway_icon_default");
    }
    return _arrowImageV;
}

- (UIView *)line{
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 2*20, 1)];
        _line.backgroundColor = RGBCOLOR(0xececec);
    }
    return _line;
}

@end
